home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 2003 September / PC Answers September 2003.iso / Software / trial / MonitorIT 5.2.06 / monitorit_fullsetup.exe / data1.cab / Js / EmailGroupFunc.js < prev    next >
Encoding:
JavaScript  |  2003-06-24  |  26.1 KB  |  825 lines

  1. //--------------------------------------------------------------------------------
  2. // Email Group Handling
  3. var EMG_Mode = "";
  4. var ELBgFlg = 0; // Email List Background color toggle
  5.  
  6. var EMGroupArr = new Array();
  7. var EMGroupArrIx = 0;
  8. var EMGroupArrRecSz = 3;
  9. var EMGLArr = new Array();
  10. var EMGLArrIx = 0;
  11. var EMGLArrRecSz = 5;
  12.  
  13. var curEMG_Name = "";
  14.  
  15. // Email Group Select Open Pop-Up
  16. function processEmailGroupButton() {
  17.     EMG_Mode = "";
  18.     PopUpEmailGroups.style.display = "";
  19.     svButtonSt();
  20.     processEMGLookup();
  21. }
  22.  
  23. // Email Group Select Close Pop-Up
  24. function processEmailGroupCloseButton() {
  25.     AR_EGSelect.style.visibility = "hidden";
  26.     reButtonSt();
  27.     PopUpEmailGroups.style.display = "none";
  28. }
  29. // Process Select Button of Email Group Pop-Up
  30. function processEmailGroupSelectButton() {
  31.     if ( AL_EAddr.value.length < 3 ) {    
  32.         AL_EAddr.value = EmailGroupList.options[EmailGroupList.selectedIndex].text;
  33.     }
  34.     else {
  35.         var fLth = AL_EAddr.value.length;
  36.         var lastCh = AL_EAddr.value.charAt(fLth-1);
  37.         var ntlastCh = AL_EAddr.value.charAt(fLth-2);
  38.         if ( (lastCh == "," || lastCh == ";" ) ||
  39.              (lastCh == " " && (ntlastCh == "," || ntlastCh == ";" )) ) {
  40.             AL_EAddr.value += " " +  EmailGroupList.options[EmailGroupList.selectedIndex].text;
  41.         }
  42.         else {
  43.             AL_EAddr.value += ", " +  EmailGroupList.options[EmailGroupList.selectedIndex].text;
  44.         }
  45.     }
  46.     processEmailGroupCloseButton();
  47. }
  48.  
  49. var saveWASeverity = "";
  50. // Email Group Manage Open
  51. function processEmailGroupManageButton() {
  52.     EMG_Mode = "Manage";
  53.     var EMG_InitSelIx = EmailGroupList.selectedIndex;
  54.     if ( top.banner.CurrentPageName == "AdminAlerts" ) {
  55.         saveWASeverity = AL_WASeveritySel.style.visibility;
  56.         AL_WASeveritySel.style.visibility = "hidden";
  57.     }
  58.     AR_EGSelect.selectedIndex = EMG_InitSelIx;
  59.     AR_EGSelect.style.visibility = "visible";
  60.     PopUpEmailGroupsManage.style.display = "";
  61.  
  62.     AR_EGSelect.innerHTML = "";
  63.     for ( var i=0; i<EMGroupArr.length-1; i+= EMGroupArrRecSz ) {
  64.         addElementToSelect(AR_EGSelect,EMGroupArr[i+1]);    
  65.     }
  66.     EmailGroupList.style.visibility = "hidden";
  67.     AL_AlertSel.style.visibility = "hidden";
  68.     SetButtonState(EGNewButton,"0");    
  69.     if ( AR_EGSelect.length > 0 ) {
  70.         SetButtonState(EGEditButton,"0");    
  71.         SetButtonState(EGDeleteButton,"0");    
  72.         SetButtonState(EGDupButton,"0");    
  73.         AR_EGSelect.focus();
  74.     }
  75.     populateEMGInput(EMG_InitSelIx); // display entry
  76. }
  77. // Email Group Manage Close
  78. function processEGDoneButton() {
  79.     processEGReset();
  80.     EMG_Mode = "";
  81.     PopUpEmailGroupsManage.style.display = "none";
  82.     EmailGroupList.style.visibility = "visible";
  83.     if ( top.banner.CurrentPageName == "AdminAlerts" ) {
  84.         AL_WASeveritySel.style.visibility = saveWASeverity;
  85.     }
  86.     AL_AlertSel.style.visibility = "visible";
  87. }
  88.  
  89. // Email Group and List Lookups
  90. function processEMGLookup() {
  91.     // Lookup Email Groups
  92.     if ( RpmCC_AL.EmailGroupLookup("0") ) { // if unable to initiate request        
  93.         top.Rstatus.Pstat("Unable to start the Email Group lookup request",true);
  94.         processResetButton();    
  95.     }
  96.     else { // waiting for OperationCompleteEvent
  97.         top.Rstatus.Pstat("One moment while Email Group lookup request completes");
  98.     }
  99. }
  100. function processEGLookupOpComplete(EGLStat) {
  101.     var wstat = new Array();
  102.     wstat = EGLStat.split(":");
  103.     if ( wstat[0] == "Err" ) {
  104.         top.Rstatus.Pstat("No Email Groups defined",true); 
  105.         EMGroupArr.length = 0;
  106.         SetButtonState(EmailGroupSelectButton,"1");    
  107.         EmailGroupList.innerHTML = "";
  108.         AR_EGSelect.innerHTML = "";
  109.         SetButtonState(EGEditButton,"1");    
  110.         SetButtonState(EGDeleteButton,"1");    
  111.         SetButtonState(EGDupButton,"1");    
  112.         AL_EGCCOne.innerHTML = "";
  113.          AR_EGName.value = "";
  114.         AR_EGDesc.value = "";
  115.         return;
  116.     }        
  117.         
  118.     EMGroupArr = EGLStat.split("~"); // parse out the lookup
  119.     EmailGroupList.innerHTML = "";
  120.  
  121.     for ( var i=0; i<EMGroupArr.length-1; i+= EMGroupArrRecSz ) {
  122.         addElementToSelect(EmailGroupList,EMGroupArr[i+1]);    
  123.     }
  124.     if ( EMG_Mode == "Manage" ) {
  125.         AR_EGSelect.innerHTML = "";
  126.         for ( var i=0; i<EMGroupArr.length-1; i+= EMGroupArrRecSz ) {
  127.             addElementToSelect(AR_EGSelect,EMGroupArr[i+1]);    
  128.         }
  129.     }
  130.     if ( AR_EGSelect.length > 0 ) {
  131.         SetButtonState(EGEditButton,"0");    
  132.         SetButtonState(EGDeleteButton,"0");    
  133.         SetButtonState(EGDupButton,"0");    
  134.     }
  135.     // Lookup Email List
  136.     if ( RpmCC_AL.EmailListLookup("0") ) { // if unable to initiate request        
  137.         top.Rstatus.Pstat("Unable to start the Email List lookup request",true);
  138.         processResetButton();    
  139.     }
  140. }
  141. function processELLookupOpComplete(ELLStat) {
  142.     EMGLArr = ELLStat.split("~"); // parse out the lookup
  143.     top.Rstatus.Pstat("Done",true);
  144.     if ( (ALMode == "New" || ALMode == "Edit") && EmailGroupList.length > 0 ) {
  145.         SetButtonState(EmailGroupSelectButton,"0");    
  146.     }
  147.     else {
  148.         SetButtonState(EmailGroupSelectButton,"1");    
  149.     }
  150.     if ( EMG_Mode == "Manage" ) {
  151.         if ( curEMG_Name != "" ) {
  152.             for ( var i=0, j=0; i<EMGroupArr.length-1; i+= EMGroupArrRecSz, ++j ) {
  153.                if ( EMGroupArr[i+1] == curEMG_Name ) {
  154.                    AR_EGSelect.selectedIndex = j;
  155.                    populateEMGInput(j);
  156.                }
  157.            }
  158.         }
  159.         else {      
  160.               populateEMGInput(0);
  161.           }
  162.     }
  163. }
  164.  
  165. // Display Email Address List for Specified Email Group
  166. function populateEMGInput(EMGn) {
  167.     var EMGix = EMGn * EMGroupArrRecSz;
  168.     if ( EMG_Mode == "Manage" ) {
  169.         AL_EGCCOne.style.backgroundColor = "threedlightshadow";
  170.     }
  171.     else {
  172.         AL_EGCCOne.style.backgroundColor = "white";
  173.     }
  174.     AL_EGCCOne.innerHTML = "";
  175.     AL_EGCCOne.style.overflow = "";
  176.     EMListArr.length = 0;
  177.     EMListIndex = 0;
  178.     EMListSelCount = 0;
  179.     EMListDispCount = 0;
  180.     formatEmailListDisplay();
  181.     if ( EMGroupArr.length == 0 ) {
  182.         return;
  183.     }
  184.  
  185.     AR_EGName.value = EMGroupArr[EMGix+1];
  186.     AR_EGDesc.value = EMGroupArr[EMGix+2];
  187.     for ( var i=0; i<EMGLArr.length-1; i+=EMGLArrRecSz ) {
  188.         // Display all Email List Addresses for this Email Group
  189.        if ( EMGroupArr[EMGix] == EMGLArr[i+3] ) {
  190.            AddToEmailList(EMGLArr[i+4],EMGLArr[i+1],EMGLArr[i+2],EMGLArr[i]);
  191.         }
  192.     }
  193.     if ( AR_EGSelect.style.visibility != "hidden" && AR_EGSelect.style.display == "" ) {
  194.        AR_EGSelect.focus();
  195.     }
  196. }
  197.  
  198. // Process Email Group Drop-down Selection
  199. function processEMGNameChange() {
  200.     for (i=0; i < AR_EGSelect.length; ++i) {
  201.         if ( AR_EGSelect.options[i].selected ) {
  202.             populateEMGInput(i);
  203.             break;
  204.         }
  205.     }
  206. }
  207.  
  208. // Process Email Group NEW and EDIT Buttons
  209. function processEGNewButton() {
  210.     EMG_Mode = "New";
  211.     commonEGNewEdit();
  212.     AR_EGName.value = "";
  213.     AR_EGDesc.value = "";
  214.     AL_EGCCOne.innerHTML = "";
  215.     AL_EGCCOne.style.overflow = "";
  216.     EMListArr.length = 0;
  217.     EMListIndex = 0;
  218.     EMListSelCount = 0;
  219.     EMListDispCount = 0;
  220.     formatEmailListDisplay();    
  221. }
  222. function processEGEditButton() {
  223.     EMG_Mode = "Edit";
  224.     commonEGNewEdit();
  225.     populateEMGInput(AR_EGSelect.selectedIndex)    
  226. }
  227. function processEGDuplicateButton() {
  228.     EMG_Mode = "New";
  229.     commonEGNewEdit();
  230.     populateEMGInput(AR_EGSelect.selectedIndex)    
  231.     AR_EGName.value = "";
  232. }
  233.  
  234. function commonEGNewEdit() {
  235.     AR_EGName.style.display = "";
  236.     AR_EGSelect.style.display = "none";
  237.     AR_EGName.className = "";
  238.     AR_EGDesc.className = "";
  239.     AR_EGDesc.value = "";
  240.     SetButtonState(EGUpdateButton,"0");    
  241.     SetButtonState(EGResetButton,"0");    
  242.     SetButtonState(EGNewButton,"1");    
  243.     SetButtonState(EGEditButton,"1");    
  244.     SetButtonState(EGDeleteButton,"1");    
  245.     SetButtonState(EGDupButton,"1");    
  246.     SetButtonState(AddEmailAddressButton,"0");    
  247.     AL_EGCCOne.style.backgroundColor = "white";
  248.     AL_EGCCOne.style.height = EGCCOneBoxHeight;
  249. }
  250.  
  251. // Process Email Group Delete Button
  252. var curEGDelIx = ""; 
  253. var curEMGLArrIx = 0;
  254. function processEGDeleteButton() {
  255.     curEGDelIx = AR_EGSelect.selectedIndex * EMGroupArrRecSz;
  256.     if ( confirm("Are you sure you want to delete the Email Group: " + EMGroupArr[curEGDelIx+1] + " ?") ) {
  257.         EMG_Mode = "Delete";
  258.         curEMGLArrIx = 0; // initialize index to scan Email Address List array
  259.           processEMLDelete(); // go do it
  260.       }
  261. }
  262. // Delete Email Address Items from Email List Table
  263. function processEMLDelete() {
  264.     while ( curEMGLArrIx < EMGLArr.length-1 ) {
  265.         // For each Email Address in List associated with Deleted Email Group
  266.        if ( EMGroupArr[curEGDelIx] == EMGLArr[curEMGLArrIx+3] ) {
  267.             if ( RpmCC_AL.EmailListRemove(EMGLArr[curEMGLArrIx]) ) { // if unable to initiate request        
  268.                 top.Rstatus.Pstat("Unable to start the Email List Delete request",true);
  269.                 processResetButton();    
  270.             }
  271.             curEMGLArrIx += EMGLArrRecSz; // bump to next
  272.             return; // wait for delete to complete
  273.         }
  274.         else {
  275.             curEMGLArrIx += EMGLArrRecSz; // bump to next
  276.             continue;    
  277.         }
  278.     }
  279.     // Now delete the Email Group
  280.     if ( RpmCC_AL.EmailGroupRemove(EMGroupArr[curEGDelIx]) ) { // if unable to initiate request        
  281.         top.Rstatus.Pstat("Unable to start the Email Group Delete request",true);
  282.         processResetButton();    
  283.     }
  284.     else { // waiting for OperationCompleteEvent
  285.         top.Rstatus.Pstat("One moment while Email Group Delete request completes");
  286.     }
  287. }
  288. // Process Email Group Delete Op Complete
  289. function processEGDeleteOpComplete(EGDStat) {
  290. var warr = new Array();
  291.     warr = EGDStat.split(":");
  292.     if ( warr[0] == "Err" ) {
  293.          top.Rstatus.Pstat("Unsuccessful Email Group Delete");
  294.          alert("Unsuccessful Email Group Delete; "+warr[1]);
  295.         processResetButton();    
  296.     }
  297.     else {
  298.          top.Rstatus.Pstat("Done");
  299.         EMG_Mode = "Manage";
  300.         curEMG_Name = ""; // clear deleted Email Group Name
  301.         processEGReset();
  302.         processEMGLookup();
  303.     }
  304. }
  305. // Email List Delete Op Complete
  306. function processELDeleteOpComplete(ELDStat) {
  307.     warr = ELDStat.split(":");
  308.     if ( warr[0] == "Err" ) {
  309.          top.Rstatus.Pstat("Unsuccessful Email Group Delete");
  310.          alert("Unsuccessful Email Group Delete "+warr[1]);
  311.         processResetButton();    
  312.     }
  313.     else {
  314.        processEMLDelete(); // go do next
  315.     }
  316. }
  317.  
  318. // Process Email Group Cancel Button
  319. function processEMGCancelButton() {
  320.     processEGReset();
  321.     EMG_Mode = "Manage";
  322.     populateEMGInput(AR_EGSelect.selectedIndex);
  323. }
  324.  
  325. function processEGReset() {
  326.     AR_EGName.style.display = "none";
  327.     AR_EGSelect.style.display = "";
  328.     AR_EGName.className = "idis";
  329.     AR_EGDesc.className = "idis";
  330.     SetButtonState(EGUpdateButton,"1");    
  331.     SetButtonState(EGResetButton,"1");    
  332.     SetButtonState(EGNewButton,"0");    
  333.     SetButtonState(AddEmailAddressButton,"1");    
  334.     SetButtonState(EditEmailAddressButton,"1");    
  335.     SetButtonState(DeleteEmailAddressButton,"1");    
  336.     if ( AR_EGSelect.length > 0 ) {
  337.         SetButtonState(EGEditButton,"0");    
  338.         SetButtonState(EGDeleteButton,"0");    
  339.         SetButtonState(EGDupButton,"0");    
  340.     }
  341.     PopUpEmailAddress.style.display = "none";
  342. }
  343.  
  344. // Process Email Address Add Button
  345. var EMAddrMode = "";
  346. function processAddEmailAddress() {
  347.     EMAddrMode = "Add";
  348.     PopUpEmailAddress.style.display = "";
  349.     processELPickInit();
  350.     EMLAddress.focus();
  351. }
  352.  
  353. // Process Email Address Add Button
  354. function processEditEmailAddress() {
  355.     EMAddrMode = "Edit";
  356.     for ( var i=0; i<EMListArr.length; i+=EMListRecSz ) {
  357.           if ( EMListArr[i+4] == 1 ) { // if selected
  358.             EMLAddress.value = EMListArr[i+1];
  359.             EMLName.value = EMListArr[i+2];
  360.             EMLDesc.value = EMListArr[i+3];
  361.             break;
  362.         }
  363.     }    
  364.     PopUpEmailAddress.style.display = "";
  365.     processELPickInit();
  366.     EMLAddress.focus();
  367. }
  368.  
  369. function processELPickButton() {
  370.     if ( AR_ELPickSel.selectedIndex >= 0 ) {
  371.         var idx = parseInt( AR_ELPickSel.options[ AR_ELPickSel.selectedIndex ].value, 10);
  372.         EMLAddress.value = EMGLArr[idx+4];
  373.         EMLName.value = EMGLArr[idx+1];
  374.         EMLDesc.value = EMGLArr[idx+2];   
  375.     }
  376. }
  377. function processELPickInit() {
  378.     var PrevEA = "";
  379.     AR_ELPickSel.innerHTML = "";
  380.     for ( var j=0; j<EMGLArr.length-1; j+=EMGLArrRecSz ) {
  381.         // Display all Email List Addresses; filter out duplicates
  382.           if ( EMGLArr[j+4] == PrevEA ) {
  383.             continue;
  384.         }
  385.         addElementToPickSelect(AR_ELPickSel,EMGLArr[j+4], j);    
  386.         PrevEA = EMGLArr[j+4];
  387.     }
  388.     if ( AR_ELPickSel.length > 0 ) {
  389.          AR_ELPickSel.selectedIndex = 0;  
  390.     }
  391. }
  392. function addElementToPickSelect(SelectObj,text,value) {
  393.     var el = document.createElement("OPTION");
  394.     el.text = text;
  395.     el.value = value;
  396.     SelectObj.options.add(el);
  397.     return el;
  398. }
  399.  
  400. // Process Email Address Add - Cancel Button
  401. function processEMLCancelButton() {
  402.     PopUpEmailAddress.style.display = "none";
  403. }
  404. // Process Email Address Add - OK Button
  405. function processEMLOKButton() {
  406.     if ( EMLAddress.value == "" ) {
  407.           alert("Please specify a Recipient Email Address"); 
  408.     }
  409.     else if ( EMAddrMode == "Add" ) {
  410.         AddToEmailList(EMLAddress.value,EMLName.value,EMLDesc.value,0);
  411.         PopUpEmailAddress.style.display = "none";
  412.     }
  413.     else { // otherwise Edit
  414.         for ( var i=0; i<EMListArr.length; i+=EMListRecSz ) {
  415.            if ( EMListArr[i+4] == 1 ) { // if selected
  416.                 EMListArr[i+1] = EMLAddress.value;
  417.                 EMListArr[i+2] = EMLName.value;
  418.                 EMListArr[i+3] = EMLDesc.value;
  419.                 break;
  420.             }
  421.         }    
  422.         PopUpEmailAddress.style.display = "none";
  423.         var Tops = "<table border='0' cellpadding='0' cellSpacing='1' width='540'>";
  424.         Tops += "<tr><td width='50%' align='left' class='optext' style='cursor:hand'>";
  425.         Tops += EMListArr[i+1]+"</td>";
  426.         Tops += "<td width='50%' align='left' class='optext' style='cursor:hand' title='" + EMListArr[i+3] + "'>";
  427.         Tops += EMListArr[i+2]+"</td></tr></table>";        
  428.         document.all["eml"+i].innerHTML = Tops; // update entry 
  429.     }
  430. }
  431.  
  432. // Display Email Address List Items
  433. function formatEmailListDisplay() {
  434.     Tops = "<table border='0' cellpadding='0' cellSpacing='1' width='540'>";
  435.     Tops += "<tr><td colspan='2' width='100%' height='2' align='center' valign='top' class='optextb' style='background-color:graytext; color:captiontext'>Email Address List</td></tr>";
  436.     
  437.     Tops += "<tr><td width='50%' height='2' align='center' valign='top' class='optextb' style='background-color:graytext; color:captiontext'>Recipient Email Address</td>";
  438.     Tops += "<td width='50%' height='2' align='center' valign='top' class='optextb' style='background-color:graytext; color:captiontext'>Name</td></tr></table>";
  439.     AL_EGCCOne.insertAdjacentHTML("afterBegin",Tops);
  440. }
  441. EMListArr = new Array();
  442. EMListIndex = 0;
  443. EMListRecSz = 5;
  444. EMListSelCount = 0;
  445. EMListDispCount = 0;
  446. function AddToEmailList(EMLA,EMLN,EMLD,EMLid) {
  447.     var i = EMListIndex;
  448.     EMListIndex += EMListRecSz;
  449.     EMListArr[i] = EMLid;
  450.     EMListArr[i+1] = EMLA;
  451.     EMListArr[i+2] = EMLN;
  452.     EMListArr[i+3] = EMLD;
  453.     EMListArr[i+4] = 0; // unselected
  454.     
  455.     if ( ++EMListDispCount > 14 ) {
  456.         AL_EGCCOne.style.overflow = "scroll"; 
  457.     }
  458.     var sbg = "";
  459.     if ( EMG_Mode != "Manage" ) {
  460.         sbg = "style='background-color:white' ";
  461.         /*
  462.         if ((ELBgFlg ^= 1) == 0) {
  463.             sbg = "style='background-color:white' ";
  464.         }
  465.         else {
  466.             sbg = "style='background-color:e8e8e8' ";
  467.         }
  468.         */
  469.     }
  470.     Tops = "<div onclick='processEMLClick(\"eml" + i +"\")' "+sbg+" id='eml"+i+"'>";
  471.     Tops += "<table border='0' cellpadding='0' cellSpacing='1' width='540'>";
  472.     Tops += "<tr><td width='50%' align='left' class='optext' style='cursor:hand'>";
  473.     Tops += EMLA+"</td>";
  474.     Tops += "<td width='50%' align='left' class='optext' style='cursor:hand' title='" + EMLD + "'>";
  475.     Tops += EMLN+"</td></tr></table></div>";
  476.     AL_EGCCOne.insertAdjacentHTML("beforeEnd",Tops);
  477. }
  478.  
  479. // Process Click of a Displayed Email Address Item
  480. function processEMLClick(sxid) {
  481.     if ( EMG_Mode != "New" && EMG_Mode != "Edit" )
  482.         return; // exit if not New or Edit   
  483.  
  484.     document.execCommand("Unselect"); // insure text is not selected
  485.      if ( sxid.charAt(0) == "e" ) {
  486.         sx = sxid.substring(3,sxid.length); // Strip off storage index
  487.         sx = eval(sx); 
  488.          var ss = EMListArr[sx+4]; // current select state
  489.         if ( ss == 0 ) { // toggle selected flag
  490.             ss = 1;
  491.             ++EMListSelCount;
  492.             SetButtonState(DeleteEmailAddressButton,"0");    
  493.         }
  494.         else {
  495.             ss = 0; 
  496.             if ( --EMListSelCount == 0 ) {
  497.                 SetButtonState(DeleteEmailAddressButton,"1");    
  498.             }
  499.         }
  500.         // Enable Edit flag only if one selected
  501.         if ( EMListSelCount == 1 ) {   
  502.             SetButtonState(EditEmailAddressButton,"0");    
  503.         }
  504.         else {
  505.             SetButtonState(EditEmailAddressButton,"1");    
  506.         }
  507.         
  508.         EMListArr[sx+4] = ss;
  509.         //rescol = ((sx/EMListRecSz) % 2 == 0 ) ? "e8e8e8" : "white";
  510.         document.all[sxid].style.backgroundColor = ( ss == 1 ) ? "scrollbar" : "white"; //rescol;
  511.     }
  512.  
  513. // Process Delete of Selected Email Address Items
  514. function processDelEmailAddress() {
  515.     for ( var i=0; i<EMListArr.length; i+=EMListRecSz ) {
  516.        if ( EMListArr[i+4] == 1 ) { // if selected
  517.             document.all["eml"+i].outerText = ""; // delete entry 
  518.             EMListArr[i+4] = 0; 
  519.             EMListArr[i+1] = "";
  520.             --EMListDispCount;
  521.         }
  522.     }
  523.     AL_EGCCOne.style.overflow = ( EMListDispCount > 14 ) ? "scroll" : ""; 
  524.     EMListSelCount = 0;
  525.     SetButtonState(EditEmailAddressButton,"1");    
  526.     SetButtonState(DeleteEmailAddressButton,"1");    
  527. }
  528.  
  529. // Process Email Group Update Button
  530. var curEMGAddID = 0;
  531. var curEMLArrIx = 0;
  532. function processEGUpdateButton() {
  533.     if ( AR_EGName.value == "" ) {
  534.         alert("Please define an Email Group Name");
  535.         AR_EGName.focus();
  536.         return;
  537.     }
  538.     if ( EMListDispCount == 0 ) {
  539.         alert("Please define one or more Email Addresses");
  540.         return; 
  541.     }
  542.     curEMG_Name = AR_EGName.value;
  543.     var astrg = AR_EGName.value+"~"+AR_EGDesc.value;
  544.     if ( EMG_Mode == "New" ) {
  545.         if ( RpmCC_AL.EmailGroupAdd(astrg) ) { // if unable to initiate request        
  546.             top.Rstatus.Pstat("Unable to start the Email Group Add request",true);
  547.             processResetButton();    
  548.         }
  549.         else { // waiting for OperationCompleteEvent
  550.             top.Rstatus.Pstat("One moment while Email Group Add request completes");
  551.         }
  552.     }
  553.     // Otherwise Edit
  554.     else {
  555.         var curEGEditIx = AR_EGSelect.selectedIndex * EMGroupArrRecSz;
  556.         curEMGAddID = EMGroupArr[curEGEditIx]; // Email Group ID
  557.         astrg = curEMGAddID+"~"+astrg;
  558.         if ( RpmCC_AL.EmailGroupReplace(astrg) ) { // if unable to initiate request        
  559.             top.Rstatus.Pstat("Unable to start the Email Group Edit request",true);
  560.             processResetButton();    
  561.         }
  562.         else { // waiting for OperationCompleteEvent
  563.             top.Rstatus.Pstat("One moment while Email Group Edit request completes");
  564.         }
  565.     }
  566. }
  567. // Process Email Group Replace Op Complete
  568. function processEGReplaceOpComplete(EGRStat) {
  569. var warr = new Array();
  570.     warr = EGRStat.split(":");
  571.     if ( warr[0] == "Err" ) {
  572.          top.Rstatus.Pstat("Unsuccessful Email Group Edit");
  573.          alert("Unsuccessful Email Group Edit; "+warr[1]);
  574.         processResetButton();    
  575.     }
  576.     else {
  577.        curEMLArrIx = 0; // initialize index
  578.        processEMLAdd();
  579.     }
  580. }
  581. // Process Email Group Add Op Complete
  582. function processEGAddOpComplete(EGAStat) {
  583. var warr = new Array();
  584.     warr = EGAStat.split(":");
  585.     if ( warr[0] == "Err" ) {
  586.          top.Rstatus.Pstat("Unsuccessful Email Group Add");
  587.          alert("Unsuccessful Email Group Add; "+warr[1]);
  588.         processResetButton();    
  589.     }
  590.     else {
  591.        warr = EGAStat.split("~");
  592.        curEMGAddID = warr[0];
  593.        curEMLArrIx = 0; // initialize index
  594.        processEMLAdd();
  595.     }
  596. }
  597. // Add and/or Edit Email Address Items to Email List Table
  598. function processEMLAdd() {
  599.     while ( curEMLArrIx < EMListArr.length ) {
  600.         if ( EMG_Mode == "New" ) {
  601.             // Process New
  602.             if ( EMListArr[curEMLArrIx+1] == "" ) {
  603.                 // Deleted Entry
  604.                 curEMLArrIx += EMListRecSz;
  605.                 continue;
  606.             }
  607.             goAddEMLEntry();
  608.         }
  609.         // Otherwise Edit
  610.         else {
  611.             // Deleted Entry
  612.             if ( EMListArr[curEMLArrIx+1] == "" ) {
  613.                 if ( EMListArr[curEMLArrIx] == 0 ) {
  614.                     // Not in Email List Table in the database
  615.                     curEMLArrIx += EMListRecSz;
  616.                     continue;
  617.                 }
  618.                 else if ( RpmCC_AL.EmailListRemove(EMListArr[curEMLArrIx]) ) { // if unable to initiate request        
  619.                     top.Rstatus.Pstat("Unable to start the Email List Delete request",true);
  620.                     processResetButton();    
  621.                 }
  622.             }
  623.             // Added Entry
  624.             else if ( EMListArr[curEMLArrIx] == 0 ) {
  625.                 goAddEMLEntry();
  626.             }
  627.             // Not Added or Deleted, Replace It
  628.             else {
  629.                 goReplaceEMLEntry();
  630.             }
  631.         }    
  632.         curEMLArrIx += EMListRecSz; // bump to next
  633.         return;    
  634.     }
  635.      top.Rstatus.Pstat("Done");
  636.     EMG_Mode = "Manage";
  637.     processEGReset();
  638.     processEMGLookup();
  639.      return;
  640. }
  641. // Email List Add Op Complete
  642. function processELAddOpComplete(ELAStat) {
  643.     var warr = ELAStat.split(":");
  644.     if ( warr[0] == "Err" ) {
  645.          top.Rstatus.Pstat("Unsuccessful Email Group Add.");
  646.          alert("Unsuccessful Email Group Add. "+warr[1]);
  647.         processResetButton();    
  648.     }
  649.     else {
  650.        processEMLAdd();
  651.     }
  652. }
  653.  
  654.  
  655. // Email List Delete Op Complete
  656. function processELEditDeleteOpComplete(ELEStat) {
  657.     var warr = ELEStat.split(":");
  658.     if ( warr[0] == "Err" ) {
  659.          top.Rstatus.Pstat("Unsuccessful Email Group Edit.");
  660.          alert("Unsuccessful Email Group Edit. "+warr[1]);
  661.         processResetButton();    
  662.     }
  663.     else {
  664.        processEMLAdd();
  665.     }
  666. }
  667.  
  668. // Replace Email Address Entry to Email List Table
  669. function goReplaceEMLEntry() {
  670.     var astrg = EMListArr[curEMLArrIx]+"~"; // EMList ID
  671.     astrg += EMListArr[curEMLArrIx+2]+"~"; // Name
  672.     astrg += EMListArr[curEMLArrIx+3]+"~"; // Desc
  673.     astrg += curEMGAddID+"~";
  674.     astrg += EMListArr[curEMLArrIx+1]; // Email Addr
  675.     if ( RpmCC_AL.EmailListReplace(astrg) ) { // if unable to initiate request        
  676.         top.Rstatus.Pstat("Unable to start the Email List Replace request",true);
  677.         processResetButton();    
  678.     }
  679. }
  680.  
  681. // Add Email Address Entry to Email List Table
  682. function goAddEMLEntry() {
  683.     var astrg = EMListArr[curEMLArrIx+2]+"~"; // Name
  684.     astrg += EMListArr[curEMLArrIx+3]+"~"; // Desc
  685.     astrg += curEMGAddID+"~";
  686.     astrg += EMListArr[curEMLArrIx+1]; // Email Addr
  687.     if ( RpmCC_AL.EmailListAdd(astrg) ) { // if unable to initiate request        
  688.         top.Rstatus.Pstat("Unable to start the Email List Add request",true);
  689.         processResetButton();    
  690.     }
  691. }
  692.  
  693. var EmailTextOrig = "";
  694. function processEmailTextButton() {
  695.     var warr = new Array();
  696.     warr = EmailText.value.split("\x0a");
  697.     var ft = warr.join("");
  698.     EmailTextOrig = ft;
  699.     EmailText.value = ft;
  700.     svButtonSt();
  701.     if ( ALMode == "New" || ALMode == "Edit" ) {
  702.          EmailText.disabled = ""; 
  703.         PopUpEmailText.style.display = "";
  704.         EmailText.focus();
  705.         ETOKButton.disabled = "";        
  706.     }
  707.     else {
  708.          EmailText.disabled = "disabled";  
  709.         PopUpEmailText.style.display = "";
  710.         ETOKButton.disabled = "disabled";        
  711.     }
  712. }
  713. // Process Email Text - Cancel Button
  714. function processETCancelButton() {
  715.     EmailText.value =    EmailTextOrig;
  716.     PopUpEmailText.style.display = "none";
  717.     reButtonSt();    
  718. }
  719. // Process Email Address Add - OK Button
  720. function processETOKButton() {
  721.     if ( EmailText.value == "" ) {
  722.         if ( !confirm("There is no Email text defined.  Is this your intention?\n -Press OK to use the standard, default Email text\n -Press Cancel to go back and define Email text") ) {
  723.             return;
  724.         }
  725.     }
  726.     EmailTextDefined.style.display = ( EmailText.value != "" ) ? "" : "none";
  727.     PopUpEmailText.style.display = "none";
  728.     reButtonSt();    
  729. }
  730.  
  731. function processEGRepButton() {
  732.     EmailGroupReport.style.display = "";
  733.     outputEGRepDetailsTextBox(); // output Details for current selected Report
  734. }
  735.  
  736. function processEGRepOKButton() {
  737.     top.Rstatus.Pstat("");
  738.     EmailGroupReport.style.display = "none";
  739.     //if ( AR_RptSel.style.visibility != "hidden" ) {
  740.     //    AR_RptSel.focus(); 
  741.     //}
  742. }
  743. function outputEGRepDetailsTextBox() {
  744.     var dtb = document.all["reptwin"];
  745.     dtb.style.height = "325px";
  746.     dtb.style.width = "640px";
  747.     dtb.style.display = "";
  748.     if ( EMGroupArr.length == 0 ) {
  749.         return;
  750.     }
  751.     /* Format Details for output */
  752.     dtb.innerHTML = ""; // clear details
  753.     var sob = "";
  754.       sob += "<center><table border='1' cellpadding='0' cellSpacing='0' width='620'>";
  755.     sob += "<tr><td width='100%' colspan='2' align='center' style='background-color:activeborder' class='optextb'>";
  756.     sob += "Email Groups Report"
  757.     sob += "</td></tr></table></center>";
  758.  
  759.     for ( var i=0; i<EMGroupArr.length-1; i+= EMGroupArrRecSz ) {
  760.        sob += "<center><table border='1' cellpadding='0' cellSpacing='0' width='620'>";
  761.          sob += "<tr><td width='50%' align='center' style='background-color:c8c8c8' class='optextb'>" + EMGroupArr[i+1] + "</td>";
  762.         sob += "<td width='50%' align='center' style='background-color:c8c8c8' class='optextb'>";
  763.         sob += ((EMGroupArr[i+2] == "") ?  " " : EMGroupArr[i+2]) + "</td></tr></table></center>";
  764.         
  765.        sob += "<center><table border='0' cellpadding='0' cellSpacing='3' width='620'>";
  766.         sob += "<tr height='3'><td width='36%' class='optext'><hr size='2' style='color:c8c8c8'></td>";
  767.         sob += "<td width='32%' class='optext'><hr size='2' style='color:c8c8c8'></td>";
  768.         sob += "<td width='32%' class='optext'><hr size='2' style='color:c8c8c8'></td></tr>";
  769.         
  770.         for ( var j=0, Count=0; j<EMGLArr.length-1; j+=EMGLArrRecSz ) {
  771.             // Display all Email List Addresses for this Email Group
  772.            if ( EMGroupArr[i] != EMGLArr[j+3] ) {
  773.                 continue;
  774.             }
  775.             sob += "<tr style='color:infotext;";
  776.            if ( Count % 2 == 0 ) {
  777.                sob += " background-color:e8e8e8' ";
  778.             }
  779.             else {
  780.                sob += " background-color:f4f4f4' ";
  781.             }            
  782.             sob += "><td width='36%' class='optext'>" + EMGLArr[j+4] + "</td>";
  783.             sob += "<td width='32%' class='optext'>" + EMGLArr[j+1] + "</td>";
  784.             sob += "<td width='32%' class='optext'>" + EMGLArr[j+2] + "</td></tr>";
  785.             ++Count;
  786.        }
  787.         sob += "<tr height='3'><td width='36%' class='optext'><hr size='2' style='color:c8c8c8'></td>";
  788.         sob += "<td width='32%' class='optext'><hr size='2' style='color:c8c8c8'></td>";
  789.         sob += "<td width='32%' class='optext'><hr size='2' style='color:c8c8c8'></td></tr>";
  790.        sob += "</table></center><br><br>";
  791.    }
  792.    dtb.insertAdjacentHTML("beforeEnd",sob);
  793.     dtb.style.overflow = (dtb.scrollHeight >= dtb.clientHeight) ? "scroll" : "";
  794.  }
  795.  
  796. function processPrintEGReport() {
  797.     if ( !top.banner.IE55orBetter ) {
  798.         alert("Print requires IE 5.5/SP1 or greater. Download current, free IE update from Microsoft's web site");
  799.         return;
  800.     }
  801.     var DiscStatWindow = null;
  802.     FakeBut.click();    // simulate event to call "savePageCoord(...)"
  803.     var wprop = "height="+top.banner.bCh+",width="+top.banner.bCw;
  804.     wprop += ",top="+(top.banner.bY-28)+",left="+(top.banner.bX-4)+",scrollbars";
  805.     var rName = ""+Math.random(); // use Random number to get unique Window name
  806.     rName = rName.substring(2,rName.length);
  807.     DiscStatWindow = window.open("",rName,wprop);
  808.     if ( DiscStatWindow == null ) {
  809.         return;   
  810.     }
  811.     var dh = "<html><head><title>MonitorIT - Email Groups Report</title>";
  812.     dh += "<link rel='stylesheet' type='text/css' href='css/Rpmstyle.css'>";
  813.     dh += "</head><body";
  814.     dh += " title='Exit to Close Window when Printing is complete'>"; 
  815.     dh += reptwin.innerHTML;    
  816.     dh += "</body></html>";
  817.     DiscStatWindow.document.open();
  818.     DiscStatWindow.document.write(dh)
  819.     DiscStatWindow.document.close();
  820.     DiscStatWindow.print();
  821. }
  822. // ---------------------------------------------------------------------------
  823.  
  824.